package com.lthlearn.config;

import com.lthlearn.util.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: 2942733239@qq.com
 * @date: 2024/11/5 14:59
 * @description: com.lthlearn.config
 * @version: 1.0
 */
@Configuration
public class MVCConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                // 不需要拦截
                // 静态资源
                .excludePathPatterns(
                        "/views/login.html",
                        "/views/index.html",
                        "/views/personal_center.html",
                        "/plugins/**",
                        "/imgs/**")
                // 后端请求
                .excludePathPatterns(
                        "/user/sendCode",
                        "/user/login",
                        "/travel/searchByLocation",
                        "/travel/searchAllByPage");
    }

}
